package servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Address;
import service.AddressServiceImpl;


@WebServlet("/InsertAddressServlet.do")
public class InsertAddressServlet extends HttpServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sheng= request.getParameter("province");
		String shi = request.getParameter("city1");
		String qu = request.getParameter("city2");
		String userName = request.getParameter("username");
		String addr = request.getParameter("addr");
		String userPhone= request.getParameter("userphone");
		String userIdentify = request.getParameter("useridentify");
		String newaddress = sheng + shi + qu + addr;
		Address address = new Address();
		address.setUserAddress(newaddress);
		address.setUserIdentify(userIdentify);
		address.setUserPhone(userPhone);
		address.setUserName(userName);
		AddressServiceImpl addressServiceImpl = new AddressServiceImpl();
		ArrayList<Address> allAddress = addressServiceImpl.insertAddress(address);
		request.getRequestDispatcher("AllAddressServlet.do").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
